
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
		<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>
	</div>
</script>
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

<script type="text/html" id="currentTableBar">
	<a style="{{d.status == 0?'':'display:none'}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
</script>
<script type="text/html" id="typeTableBar">
	{{d.type == 1?'报销':''}}
	{{d.type == 2?'预支':''}}
</script>
<script type="text/html" id="statusTableBar">
	{{d.status == 0?'驳回':''}}
	{{d.status == 1?'审核中':''}}
	{{d.status == 2?'放款中':''}}
	{{d.status == 3?'完成':''}}
</script>
<script>
//修改报销明细
function save_baoxiao(id,title,url){
	layer.open({
        type: 2,
        title:title,
        area: ['60%', '70%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('"+url+"')}?id="+id
    });
    //layer.full(index);
}

	var $,form,table,laydate
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		var $ = layui.jquery , form = layui.form , table = layui.table , laydate = layui.laydate

		table.render({
			elem: '#currentTableId',
			id:'list_sp_pending',
			url: '{:url("list_sp_pending")}?t=json',
			method : 'post',
			toolbar: true,
			cols: [[
				{ field: 'create_time', title: '提交日期'},
				{ field: 'type', title: '类型',toolbar: '#typeTableBar'},
				{ field: 'title', title: '提交类别' },
				{ field: 'money', title: '金额'},
				{ field: 'remark', title: '费用明细' },
				{ field: 'screenshot_url', title: '凭证',  templet: function(d){
			          return d.screenshot_url?'<img  src="'+d.screenshot_url+'">':''
			    }},
			    { field: 'employ_time', title: '使用时间',  templet: function(d){
			          return d.employ_time?date('Y-m-d',d.employ_time):''
			    }},
			    { field: 'status', title: '状态',toolbar: '#statusTableBar' },
			    { field: 'user_name', title: '申请人' },
				{ title: '操作', minWidth: 150, fixed: 'right', toolbar: '#currentTableBar', align: "center" }
			]],
			limit: 30,
			page: true,
			skin: 'line'
		});

		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(currentTableFilter)', function (obj) {
			switch (obj.event) {
				case 'recharge':
					
				break;
				
			}
		});

		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					//
					if(data.type == 1){
						save_baoxiao(data.id,'编辑报销明细','save_baoxiao');
					}else if(data.type == 2){
						save_baoxiao(data.id,'编辑预支明细','save_yuzhi');
					}
					
				break;
				
			}
		});
		//监听行单击事件
		table.on('row(currentTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});
		
	});
	//重载数据表
	function get_pending(msg){
		table.reload('list_sp_pending', {
			  url: '{:url("list_sp_pending")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>
